<template>
    
</template>

<script>
    export default {
        onLoad() {
			},
			onShow() {
				if(this.onshows){
					this.toFlash();
				}
				console.log(this.onshows);
			},
			data() {
				return {
					onshows:true
				}
			},
			onBackPress(){
				this.backlast();
			},
			methods: {
			   backlast(){
				uni.navigateTo({
					url:'/pages/index/index'
				})
			   },
				tocancel:function(){
				   uni.scanCode({
					   success: function (res) {
						   console.log('条码类型：' + res.scanType);
						   console.log('条码内容：' + res.result);
					   }
				   });
				},
				toFlash: function() {
				   // 只允许通过相机扫码
				 
					this.onshows=false;
					let thsi=this;
				   uni.scanCode({
					   onlyFromCamera: true,
					   success: function (res) {
						   console.log('条码类型：' + res.scanType);
						   console.log('条码内容：' + res.result);
						   uni.navigateTo({
								url: '/pages/VerificationSigned/disbvsData?data='+res.result,
						   })
					   },
					   fail :function(res){
						   if(res.errMsg=="scanCode:fail cancel"){
								uni.switchTab({
									url:'/pages/index/index'
								})					
						   }else{
							   uni.switchTab({
							   	url:'/pages/index/index'
							   })	
							   uni.showModal({
							   	title: '提示',
							   	content: '此二维码与任务不符',
							   	showCancel: false
							   })
						   }
						   
					   }
				   });
				},
				toscan: function() {
				  // 调起条码扫描
				  uni.scanCode({
					  scanType: ['barCode'],
					  success: function (res) {
						  console.log('条码类型：' + res.scanType);
						  console.log('条码内容：' + res.result);
						  uni.navigateTo({
							url: '/pages/VerificationSigned/disbvsData'
						  })
					  }
				  });
				}
			}
		}
</script>

<style>
	/* 导航栏 */
	.backs {
		position: absolute;
		z-index: 11111;
		top: 85upx;
		left: 30upx;
		display: flex;
		color: #000;
		line-height: 30upx;
		align-items: center;
		display: inline-block;
	}
	
	.backs image {
		width:45upx;
		height:45upx;
		margin-right: 14upx;
	}
    .barcode {
        width: 750rpx;
        height: 700rpx;
        background-color: #808080;
    }

    .btn {
        top: 20rpx;
        width: 730rpx;
        margin-left: 10rpx;
        margin-top: 10rpx;
        background-color: #458B00;
        border-radius: 10rpx;
    }
</style>